import java.util.Random;

public class ArrayHomework02 {
    public static void main(String[] args) {
        int[] arr = new int[10];
        double sum = 0;
        double avg = 0;
        int indexMax = 0;
        int indexMin = 0;
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (int) (Math.random() * 100) + 1;
        }
        int tempMax = arr[0];
        int tempMin = arr[0];
        int find = -1;
        System.out.println("正序打印：");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + "\t");
            if (arr[i] > tempMax) {
                tempMax = arr[i];
                indexMax = i;
            }
            if (arr[i] < tempMin) {
                tempMin = arr[i];
                indexMin = i;
            }
            if (arr[i] == 8) {
                find = i;
            }
            sum += arr[i];
        }
        System.out.println();
        System.out.println("倒序打印：");
        for (int length = arr.length - 1; length >= 0; length--) {
            System.out.print(arr[length] + "\t");
        }
        avg = sum / arr.length;
        System.out.println();
        System.out.println("平均值为：" + avg + "，最大值下标为：" + indexMax + "，最小值下标为：" + indexMin);
        if (find != -1) {
            System.out.println("该数组中有8");
        } else {
            System.out.println("该数组中没有8");
        }
    }
}